package com.aspose.cells;

class zaws extends zawp {
   private int j;
   private int k;
   private boolean l;
   private int m;
   private int n;
   private int o;
   private int p;

   public zaws(zahn[] var1, zagj var2, zaay var3) {
      super(var1, var2, var3);
      this.j = var1[0].c();
      this.k = var1[0].d();
      this.l = false;
   }

   private zaws(zaws var1, zaay var2) {
      super(var1.e(var2), (zagj)var1.c.a(var2), var2);
      this.d = var1.d;
      this.j = var1.j;
      this.k = var1.k;
      if (var1.l) {
         this.l = true;
         this.m = var1.m;
         this.o = var1.o;
         this.n = var1.n;
         this.p = var1.p;
      } else {
         this.l = false;
      }

   }

   public zahn b(zaay var1) {
      return new zaws(this, var1);
   }

   public boolean b(int var1, int var2) {
      zahn var3;
      if (this.g < this.b.length) {
         var3 = this.b[this.g];
         if (var1 == var3.i() && var2 == var3.j()) {
            return true;
         }
      }

      this.h = null;
      int var4 = this.j;
      int var5 = this.k;
      this.g = 0;

      for(int var7 = 0; var7 < this.b.length; ++var7) {
         var3 = this.b[var7];
         if (var3.b(var1, var2)) {
            this.f[var7] = true;
            int var6 = var3.i() - var4;
            if (var6 == 0) {
               var6 = var3.j() - var5;
            }

            if (var6 > 0) {
               this.e[var7] = false;
            } else {
               this.e[var7] = true;
               if (var6 < 0 && this.g < var7) {
                  do {
                     this.e[this.g] = false;
                     ++this.g;
                  } while(this.g != var7);
               }
            }
         } else {
            this.f[var7] = false;
            this.e[var7] = false;
            if (this.g == var7) {
               ++this.g;
            }
         }
      }

      return this.g < this.b.length;
   }

   public boolean a(int var1) {
      return this.b(var1 / this.k, var1 % this.k);
   }

   public boolean g() {
      zahn var1;
      if (this.i > -1) {
         var1 = this.b[this.i];
         if (this.f[this.i]) {
            this.i = -1;
            return this.b(var1.i(), var1.j());
         } else {
            this.i = -1;
            return false;
         }
      } else {
         this.h = null;
         int var2 = this.j;
         int var3 = this.k;
         this.g = 0;

         for(int var5 = 0; var5 < this.b.length; ++var5) {
            var1 = this.b[var5];
            int var4;
            if (this.e[var5]) {
               if (var1.g()) {
                  var4 = var1.i() - var2;
                  if (var4 == 0) {
                     var4 = var1.j() - var3;
                  }

                  if (var4 > 0) {
                     this.e[var5] = false;
                  } else if (var4 < 0 && this.g < var5) {
                     do {
                        this.e[this.g] = false;
                        ++this.g;
                     } while(this.g != var5);
                  }
               } else {
                  this.f[var5] = false;
                  this.e[var5] = false;
               }
            } else {
               var4 = var1.i() - var2;
               if (var4 == 0) {
                  var4 = var1.j() - var3;
               }

               if (var4 == 0) {
                  this.e[var5] = true;
               } else if (var4 < 0 && this.g < var5) {
                  this.e[var5] = true;

                  do {
                     this.e[this.g] = false;
                     ++this.g;
                  } while(this.g != var5);
               }
            }
         }

         return this.g < this.b.length;
      }
   }

   public zahn b(int var1) {
      zahn[] var2 = new zahn[this.b.length];

      for(int var3 = 0; var3 < this.b.length; ++var3) {
         var2[var3] = this.b[var3].b(var1);
      }

      return new zawr(var2, this.c, this.a, this.d);
   }

   public zahn c(int var1) {
      zahn[] var2 = new zahn[this.b.length];

      for(int var3 = 0; var3 < this.b.length; ++var3) {
         var2[var3] = this.b[var3].c(var1);
      }

      return new zawr(var2, this.c, this.a, this.d);
   }

   public zahn c(zaay var1) {
      if (!this.l) {
         this.C();
      }

      zbvm var2 = new zbvm(this, this.d, this.m, this.o, this.n, this.p, this.j, this.k);
      return new zawy(new zaws(this, var1), var2, var1);
   }

   public boolean m() {
      return false;
   }

   public boolean n() {
      return false;
   }

   public int c() {
      return this.j;
   }

   public int d() {
      return this.k;
   }

   public int e() {
      return this.j * this.k;
   }

   public boolean q() {
      return this.l;
   }

   public int r() {
      if (!this.l) {
         this.C();
      }

      return this.m;
   }

   public int s() {
      if (!this.l) {
         this.C();
      }

      return this.n;
   }

   public int t() {
      if (!this.l) {
         this.C();
      }

      return this.o;
   }

   public int u() {
      if (!this.l) {
         this.C();
      }

      return this.p;
   }

   private void C() {
      this.l = true;
      zahn var1 = this.b[0];
      this.m = var1.r();
      this.o = var1.t();
      this.n = var1.s();
      this.p = var1.u();

      for(int var2 = 1; var2 < this.b.length; ++var2) {
         var1 = this.b[var2];
         this.m = Math.min(this.m, var1.r());
         this.o = Math.min(this.o, var1.t());
         this.n = Math.max(this.n, var1.s());
         this.p = Math.max(this.p, var1.u());
      }

   }
}
